All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JTable

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JTable

public class JTable
extends JComponent
implements TableModelListener, Scrollable, TableColumnModelListener, ListSelectionListener, CellEditorListener, Accessible
JTable is a user-interface component that presents data in a two-dimensional table format. The JTable has many features that make it possible to customize its rendering and editing but provides defaults for these features so that simple tables can be set up easily. For example, to set up a table with 10 rows and 10 columns of numbers:

       TableModel dataModel = new AbstractTableModel() {
           public int getColumnCount() { return 10; }
           public int getRowCount() { return 10;}
           public Object getValueAt(int row, int col) { return new Integer(row*col); }
       };
       JTable table = new JTable(dataModel);
       JScrollPane scrollpane = new JScrollPane(table);
  

Because the JTable is now much easier to set up with custom models the DefaultTableModel is less useful than it was in previous releases. Instead of copying the data in an application into the DefaultTableModel, we recommend wrapping it in the methods of the TableModel interface and passing the real data to the JTable as above. This technique is nearly as concise as using a DefaultTableModel and starting this way has a number of advantages over the longer term. In particular: it is a scalable technique, is easier to handle dynamic or editable tables and often results in much more efficient applications because the model is free to choose the internal representation that best suits the data.

The "Table" directory in the examples/demo area gives a number of complete examples of JTable usage, covering how the JTable can be used to provide an editable view of data taken from a database and how to modify the columns in the display to use specialized renderers and editors.

The JTable uses integers exclusively to refer to both the rows and the columns of the model that it displays. The JTable simply takes a tabular range of cells and uses getValueAt(int, int) to retrieve and display the values from the model.

If getTableHeader().setReorderingAllowed(boolean) is used to enable column reordering columns may be rearranged in the JTable so that the view's columns appear in a different order to the columns in the model. This does not affect the implementation of the model at all: when the columns are reordered, the JTable maintains the new order of the columns internally and converts its column indices before querying the model. So, when writing a TableModel, it is not necessary to listen for column reordering events as the the model will be queried in its own co-ordinate system regardless of what is happening in the view. In the examples area there is a demonstration of a sorting algorithm making use of exactly this technique to interpose yet another co-ordinate system where the order of the rows is changed, rather than the order of the columns.

The general rule for the JTable API and the APIs of all its associated classes, including the the column model and both the row and column selection models, is: methods using integer indices for rows and columns always use the co-ordinate system of the view. There are three exceptions to this rule:

The TableColumn provides a slot for holding an identifier or "tag" for each column and the JTable and TableColumModel both support getColumn(Object id) conveniences for locating columns by their identifier. If no identifier is explicitly set, the TableColumn returns its header value (the name of the column) as a default. A different identifier, which can be of any type, can be set using the TableColumn's setIdentifier() method. All of the JTable's functions operate correctly regardless of the type and uniqueness of these identifiers.

The convertColumnIndexToView() and convertColumnIndexToModel() methods have been provided to convert between the two co-ordinate systems but they are rarely needed during normal use.

See How to Use Tables in The Java Tutorial for further documentation.

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JTable key assignments.

Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.


Variable Index

 o AUTO_RESIZE_ALL_COLUMNS
Proportionately resize all columns when table is resized
 o AUTO_RESIZE_LAST_COLUMN
Auto resize last column only when table is resized
 o AUTO_RESIZE_OFF
Do not auto resize column when table is resized.
 o autoCreateColumnsFromModel
The table will query the TableModel to build the default set of columns if this is true.
 o autoResizeMode
This mode value determines if table automatically resizes the width the table's columns to take up the entire width of the table, and how it does the resizing.
 o cellEditor
The object that overwrites the screen real estate occupied by the current cell and allows the user to change those contents.
 o cellSelectionEnabled
If this is true, then both a row selection and a column selection can be non-empty at the same time, the selected cells are the the cells whose row and column are both selected.
 o columnModel
The TableColumnModel of the table
 o dataModel
The TableModel of the table
 o defaultEditorsByColumnClass
A table of objects that display and edit the contents of a cell, indexed by class.
 o defaultRenderersByColumnClass
A table of objects that display the contents of a cell, indexed by class.
 o editingColumn
Identifies the column of the cell being edited.
 o editingRow
Identifies the row of the cell being edited.
 o editorComp
If editing, Component that is handling the editing.
 o gridColor
The color of the grid
 o preferredViewportSize
Used by the Scrollable interface to determine the initial visible area
 o rowHeight
The height of all rows in the table
 o rowMargin
The height margin between rows
 o rowSelectionAllowed
Row selection allowed in this table
 o selectionBackground
The background color of selected cells
 o selectionForeground
The foreground color of selected cells
 o selectionModel
The ListSelectionModel of the table, used to keep track of row selections
 o showHorizontalLines
The table draws horizontal lines between cells if showHorizontalLines is true
 o showVerticalLines
The table draws vertical lines between cells if showVerticalLines is true
 o tableHeader
The TableHeader working with the table

Constructor Index

 o JTable()
Constructs a default JTable which is initialized with a default data model, a default column model, and a default selection model.
 o JTable(int, int)
Constructs a JTable with numRows and numColumns of empty cells using the DefaultTableModel.
 o JTable(Object[][], Object[])
Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames.
 o JTable(TableModel)
Constructs a JTable which is initialized with dm as the data model, a default column model, and a default selection model.
 o JTable(TableModel, TableColumnModel)
Constructs a JTable which is initialized with dm as the data model, cm as the column model, and a default selection model.
 o JTable(TableModel, TableColumnModel, ListSelectionModel)
Constructs a JTable which is initialized with dm as the data model, cm as the column model, and sm as the selection model.
 o JTable(Vector, Vector)
Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames.

Method Index

 o addColumn(TableColumn)
Appends aColumn to the end of the array of columns held by the JTable's column model.
 o addColumnSelectionInterval(int, int)
Adds the columns from index0 to index0 inclusive to the current selection.
 o addNotify()
Calls configureEnclosingScrollPane.
 o addRowSelectionInterval(int, int)
Adds the rows from index0 to index0 inclusive to the current selection.
 o clearSelection()
Deselects all selected columns and rows.
 o columnAdded(TableColumnModelEvent)
Tells listeners that a column was added to the model.
 o columnAtPoint(Point)
Returns the index of the column that point lies in, or -1 if it lies outside the receiver's bounds.
 o columnMarginChanged(ChangeEvent)
Tells listeners that a column was moved due to a margin change.
 o columnMoved(TableColumnModelEvent)
Tells listeners that a column was repositioned.
 o columnRemoved(TableColumnModelEvent)
Tells listeners that a column was removed from the model.
 o columnSelectionChanged(ListSelectionEvent)
Tells listeners that the selection model of the TableColumnModel changed.
 o configureEnclosingScrollPane()
If the JTable is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's tableHeader as the columnHeaderView of the scrollpane.
 o convertColumnIndexToModel(int)
Return the index of the column in the model whose data is being displayed in the column viewColumnIndex in the display.
 o convertColumnIndexToView(int)
Return the index of the column in the view which is displaying the data from the column modelColumnIndex in the model.
 o createDefaultColumnModel()
Returns the default column model object which is a DefaultTableColumnModel.
 o createDefaultColumnsFromModel()
This method will create default columns for the table from the data model using the getColumnCount() and getColumnType() methods defined in the TableModel interface.
 o createDefaultDataModel()
Returns the default table model object which is a DefaultTableModel.
 o createDefaultEditors()
Creates default cell editors for Objects, numbers, and boolean values.
 o createDefaultRenderers()
 o createDefaultSelectionModel()
Returns the default selection model object which is a DefaultListSelectionModel.
 o createDefaultTableHeader()
Returns the default table header object which is a JTableHeader.
 o createScrollPaneForTable(JTable)
Equivalent to new JScrollPane(aTable). Deprecated.
 o editCellAt(int, int)
Programmatically starts editing the cell at row and column, if the cell is editable.
 o editCellAt(int, int, EventObject)
Programmatically starts editing the cell at row and column, if the cell is editable.
 o editingCanceled(ChangeEvent)
Invoked when editing is canceled.
 o editingStopped(ChangeEvent)
Invoked when editing is finished.
 o getAccessibleContext()
Get the AccessibleContext associated with this JComponent
 o getAutoCreateColumnsFromModel()
Returns whether the table will create default columns from the model.
 o getAutoResizeMode()
Returns auto resize mode of the table.
 o getCellEditor()
Return the cellEditor.
 o getCellRect(int, int, boolean)
Returns a rectangle locating the cell that lies at the intersection of row and column.
 o getCellSelectionEnabled()
Returns true if simultaneous row and column selections are allowed
 o getColumn(Object)
Returns the TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals().
 o getColumnClass(int)
Returns the type of the column at the specified view position.
 o getColumnCount()
Returns the number of columns in the column model, note this may be different to the number of columns in the table model.
 o getColumnModel()
Returns the TableColumnModel that contains all column inforamtion of this table.
 o getColumnName(int)
Returns the name of the column at the specified view position.
 o getColumnSelectionAllowed()
Returns true if columns can be selected.
 o getDefaultEditor(Class)
Returns the editor to be used when no editor has been set in a TableColumn.
 o getDefaultRenderer(Class)
Returns the renderer to be used when no renderer has been set in a TableColumn.
 o getEditingColumn()
This returns the index of the editing column.
 o getEditingRow()
Returns the index of the editing row.
 o getEditorComponent()
If the receiver is currently editing this will return the Component that was returned from the CellEditor.
 o getGridColor()
Returns the color used to draw grid lines.
 o getIntercellSpacing()
Returns the horizontal and vertical spacing between cells.
 o getModel()
Returns the TableModel that provides the data displayed by the receiver.
 o getPreferredScrollableViewportSize()
Returns the preferred size of the viewport for this table.
 o getRowCount()
Returns the number of rows in the table.
 o getRowHeight()
Returns the height of a table row in the receiver.
 o getRowSelectionAllowed()
Returns true if rows can be selected.
 o getScrollableBlockIncrement(Rectangle, int, int)
Returns The visibleRect.height or visibleRect.width, depending on the table's orientation.
 o getScrollableTracksViewportHeight()
Returns false to indicate that the height of the viewport does not determine the height of the table.
 o getScrollableTracksViewportWidth()
Returns false to indicate that the width of the viewport does not determine the width of the table.
 o getScrollableUnitIncrement(Rectangle, int, int)
Returns the scroll increment that completely exposes one new row or column (depending on the orientation).
 o getSelectedColumn()
Returns the index of the last column selected or added to the selection.
 o getSelectedColumnCount()
Returns the number of selected columns.
 o getSelectedColumns()
Returns the indices of all selected columns.
 o getSelectedRow()
Returns the index of the last row selected or added to the selection.
 o getSelectedRowCount()
Returns the number of selected rows.
 o getSelectedRows()
Returns the indices of all selected rows.
 o getSelectionBackground()
Returns the background color for selected cells.
 o getSelectionForeground()
Returns the foreground color for selected cells.
 o getSelectionModel()
Returns the ListSelectionModel that is used to maintain row selection state.
 o getShowHorizontalLines()
Returns true if the receiver draws horizontal lines between cells, false if it doesn't.
 o getShowVerticalLines()
Returns true if the receiver draws vertical lines between cells, false if it doesn't.
 o getTableHeader()
Returns the tableHeader working with this JTable.
 o getToolTipText(MouseEvent)
Overrides JComponent's setToolTipText method to allow use of the renderer's tips (if the renderer has text set).
 o getUI()
Returns the L&F object that renders this component.
 o getUIClassID()
Returns the name of the L&F class that renders this component.
 o getValueAt(int, int)
Returns the cell value at row and column.
 o initializeLocalVars()
Initializes table properties to their default values.
 o isCellEditable(int, int)
Returns true if the cell at row and column is editable.
 o isCellSelected(int, int)
Returns true if the cell at the specified position is selected.
 o isColumnSelected(int)
Returns true if the column at the specified index is selected
 o isEditing()
Returns true is the table is editing a cell.
 o isOpaque()
Returns true to indicate that this component paints every pixel in its range.
 o isRowSelected(int)
Returns true if the row at the specified index is selected
 o moveColumn(int, int)
Moves the column column to the position currently occupied by the column targetColumn.
 o prepareEditor(TableCellEditor, int, int)
Sets up the specified editor using the value at the specified cell.
 o removeColumn(TableColumn)
Removes aColumn from the JTable's array of columns.
 o removeColumnSelectionInterval(int, int)
Deselects the columns from index0 to index0 inclusive.
 o removeEditor()
Discard the editor object and return the real estate it used to cell rendering.
 o removeRowSelectionInterval(int, int)
Deselects the rows from index0 to index0 inclusive.
 o resizeAndRepaint()
Properly sizes the receiver and its header view, and marks it as needing display.
 o rowAtPoint(Point)
Returns the index of the row that point lies in, or -1 if is not in the range [0, getRowCount()-1].
 o selectAll()
If a column is selected, then this selects all columns.
 o setAutoCreateColumnsFromModel(boolean)
Sets the table's autoCreateColumnsFromModel flag.
 o setAutoResizeMode(int)
Sets the table's auto resize mode when the table is resized.
 o setCellEditor(TableCellEditor)
Set the cellEditor variable.
 o setCellSelectionEnabled(boolean)
Sets whether this table allows both a column selection and a row selection to exist at the same time.
 o setColumnModel(TableColumnModel)
Sets the column model for this table to newModel and registers with for listner notifications from the new column model.
 o setColumnSelectionAllowed(boolean)
Sets whether the columns in this model can be selected.
 o setColumnSelectionInterval(int, int)
Selects the columns from index0 to index1 inclusive.
 o setDefaultEditor(Class, TableCellEditor)
Set a default editor to be used if no editor has been set in a TableColumn.
 o setDefaultRenderer(Class, TableCellRenderer)
Set a default renderer to be used if no renderer has been set in a TableColumn.
 o setEditingColumn(int)
Set the editingColumn variable.
 o setEditingRow(int)
Set the editingRow variable.
 o setGridColor(Color)
Sets the color used to draw grid lines to color and redisplays the receiver.
 o setIntercellSpacing(Dimension)
Sets the width and height between cells to newSpacing and redisplays the receiver.
 o setModel(TableModel)
Sets the data model for this table to newModel and registers with for listner notifications from the new data model.
 o setPreferredScrollableViewportSize(Dimension)
Sets the preferred size of the viewport for this table.
 o setRowHeight(int)
Sets the height for rows to newRowHeight and invokes tile
 o setRowSelectionAllowed(boolean)
Sets whether the rows in this model can be selected.
 o setRowSelectionInterval(int, int)
Selects the rows from index0 to index1 inclusive.
 o setSelectionBackground(Color)
Set the background color for selected cells.
 o setSelectionForeground(Color)
Set the foreground color for selected cells.
 o setSelectionMode(int)
Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals.
 o setSelectionModel(ListSelectionModel)
Sets the row selection model for this table to newModel and registers with for listner notifications from the new selection model.
 o setShowGrid(boolean)
Sets whether the receiver draws grid lines around cells.
 o setShowHorizontalLines(boolean)
Sets whether the receiver draws horizontal lines between cells.
 o setShowVerticalLines(boolean)
Sets whether the receiver draws vertical lines between cells.
 o setTableHeader(JTableHeader)
Sets the tableHeader working with this JTable to newHeader.
 o setUI(TableUI)
Sets the L&F object that renders this component.
 o setValueAt(Object, int, int)
Sets the value for the cell at row and column.
 o sizeColumnsToFit(boolean)
This method will resize one or more columns of the table so that the sum width of all columns will equal to the width of the table.
 o tableChanged(TableModelEvent)
The TableModelEvent should be constructed in the co-ordinate system of the model, the appropriate mapping to the view co-ordinate system is performed by the JTable when it recieves the event.
 o updateUI()
Notification from the UIManager that the L&F has changed.
 o valueChanged(ListSelectionEvent)
Tells listeners that the selection changed.

Variables

 o AUTO_RESIZE_OFF
 public static final int AUTO_RESIZE_OFF
Do not auto resize column when table is resized.

 o AUTO_RESIZE_LAST_COLUMN
 public static final int AUTO_RESIZE_LAST_COLUMN
Auto resize last column only when table is resized

 o AUTO_RESIZE_ALL_COLUMNS
 public static final int AUTO_RESIZE_ALL_COLUMNS
Proportionately resize all columns when table is resized

 o dataModel
 protected TableModel dataModel
The TableModel of the table

 o columnModel
 protected TableColumnModel columnModel
The TableColumnModel of the table

 o selectionModel
 protected ListSelectionModel selectionModel
The ListSelectionModel of the table, used to keep track of row selections

 o tableHeader
 protected JTableHeader tableHeader
The TableHeader working with the table

 o rowHeight
 protected int rowHeight
The height of all rows in the table

 o rowMargin
 protected int rowMargin
The height margin between rows

 o gridColor
 protected Color gridColor
The color of the grid

 o showHorizontalLines
 protected boolean showHorizontalLines
The table draws horizontal lines between cells if showHorizontalLines is true

 o showVerticalLines
 protected boolean showVerticalLines
The table draws vertical lines between cells if showVerticalLines is true

 o autoResizeMode
 protected int autoResizeMode
This mode value determines if table automatically resizes the width the table's columns to take up the entire width of the table, and how it does the resizing.

 o autoCreateColumnsFromModel
 protected boolean autoCreateColumnsFromModel
The table will query the TableModel to build the default set of columns if this is true.

 o preferredViewportSize
 protected Dimension preferredViewportSize
Used by the Scrollable interface to determine the initial visible area

 o rowSelectionAllowed
 protected boolean rowSelectionAllowed
Row selection allowed in this table

 o cellSelectionEnabled
 protected boolean cellSelectionEnabled
If this is true, then both a row selection and a column selection can be non-empty at the same time, the selected cells are the the cells whose row and column are both selected.

 o editorComp
 protected transient Component editorComp
If editing, Component that is handling the editing.

 o cellEditor
 protected transient TableCellEditor cellEditor
The object that overwrites the screen real estate occupied by the current cell and allows the user to change those contents.

 o editingColumn
 protected transient int editingColumn
Identifies the column of the cell being edited.

 o editingRow
 protected transient int editingRow
Identifies the row of the cell being edited.

 o defaultRenderersByColumnClass
 protected transient Hashtable defaultRenderersByColumnClass
A table of objects that display the contents of a cell, indexed by class.

 o defaultEditorsByColumnClass
 protected transient Hashtable defaultEditorsByColumnClass
A table of objects that display and edit the contents of a cell, indexed by class.

 o selectionForeground
 protected Color selectionForeground
The foreground color of selected cells

 o selectionBackground
 protected Color selectionBackground
The background color of selected cells

Constructors

 o JTable
 public JTable()
Constructs a default JTable which is initialized with a default data model, a default column model, and a default selection model.

See Also:
createDefaultDataModel, createDefaultColumnModel, createDefaultSelectionModel
 o JTable
 public JTable(TableModel dm)
Constructs a JTable which is initialized with dm as the data model, a default column model, and a default selection model.

Parameters:
dm - The data model for the table
See Also:
createDefaultColumnModel, createDefaultSelectionModel
 o JTable
 public JTable(TableModel dm,
               TableColumnModel cm)
Constructs a JTable which is initialized with dm as the data model, cm as the column model, and a default selection model.

Parameters:
dm - The data model for the table
cm - The column model for the table
See Also:
createDefaultSelectionModel
 o JTable
 public JTable(TableModel dm,
               TableColumnModel cm,
               ListSelectionModel sm)
Constructs a JTable which is initialized with dm as the data model, cm as the column model, and sm as the selection model. If any of the parameters are null this method will initialize the table with the corresponding default model. The autoCreateColumnsFromModel flag is set to false if cm is non-null, otherwise it is set to true and the column model is populated with suitable TableColumns for the columns in dm.

Parameters:
dm - The data model for the table
cm - The column model for the table
sm - The row selection model for the table
See Also:
createDefaultDataModel, createDefaultColumnModel, createDefaultSelectionModel
 o JTable
 public JTable(int numRows,
               int numColumns)
Constructs a JTable with numRows and numColumns of empty cells using the DefaultTableModel. The columns will have names of the form "A", "B", "C", etc.

Parameters:
numRows - The number of rows the table holds
numColumns - The number of columns the table holds
See Also:
DefaultTableModel
 o JTable
 public JTable(Vector rowData,
               Vector columnNames)
Constructs a JTable to display the values in the Vector of Vectors, rowData, with column names, columnNames. The Vectors contained in rowData should contain the values for that row. In other words, the value of the cell at row 1, column 5 can be obtained with the following code:

((Vector)rowData.elementAt(1)).elementAt(5);

All rows must be of the same length as columnNames.

Parameters:
rowData - The data for the new table
columnNames - Names of each column
 o JTable
 public JTable(Object rowData[][],
               Object columnNames[])
Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames. rowData is an Array of rows, so the value of the cell at row 1, column 5 can be obtained with the following code:

 rowData[1][5]; 

All rows must be of the same length as columnNames.

Parameters:
rowData - The data for the new table
columnNames - Names of each column

Methods

 o addNotify
 public void addNotify()
Calls configureEnclosingScrollPane.

Overrides:
addNotify in class JComponent
See Also:
configureEnclosingScrollPane
 o configureEnclosingScrollPane
 protected void configureEnclosingScrollPane()
If the JTable is the viewportView of an enclosing JScrollPane (the usual situation), configure this ScrollPane by, amongst other things, installing the table's tableHeader as the columnHeaderView of the scrollpane. When a JTable is added to a JScrollPane in the usual way, using new JScrollPane(myTable), addNotify is called in the JTable (when the table is added to the viewport). JTable's addNotify method in turn calls this method which is protected so that this default installation procedure can be overridden by a subclass.

See Also:
addNotify
 o createScrollPaneForTable
 public static JScrollPane createScrollPaneForTable(JTable aTable)
Note: createScrollPaneForTable() is deprecated. As of Swing version 1.0.2, replaced by new JScrollPane(aTable).

Equivalent to new JScrollPane(aTable).

 o setTableHeader
 public void setTableHeader(JTableHeader newHeader)
Sets the tableHeader working with this JTable to newHeader. It is legal to have a null tableHeader.

Parameters:
newHeader - new tableHeader
See Also:
getTableHeader
 o getTableHeader
 public JTableHeader getTableHeader()
Returns the tableHeader working with this JTable.

Returns:
the tableHeader working with the receiver
See Also:
setTableHeader
 o setRowHeight
 public void setRowHeight(int newHeight)
Sets the height for rows to newRowHeight and invokes tile

Parameters:
newRowHeight - new row height
Throws: IllegalArgumentException
If newRowHeight is less than 1.
See Also:
getRowHeight
 o getRowHeight
 public int getRowHeight()
Returns the height of a table row in the receiver. The default row height is 16.0.

Returns:
the height of each row in the receiver
See Also:
setRowHeight
 o setIntercellSpacing
 public void setIntercellSpacing(Dimension newSpacing)
Sets the width and height between cells to newSpacing and redisplays the receiver.

Parameters:
newSpacing - The new width and height intercellSpacing
See Also:
getIntercellSpacing
 o getIntercellSpacing
 public Dimension getIntercellSpacing()
Returns the horizontal and vertical spacing between cells. The default spacing is (3, 2).

Returns:
the horizontal and vertical spacing between cells
See Also:
setIntercellSpacing
 o setGridColor
 public void setGridColor(Color newColor)
Sets the color used to draw grid lines to color and redisplays the receiver. The default color is gray.

Parameters:
color - new color of the grid
Throws: IllegalArgumentException
if color is null
See Also:
getGridColor
 o getGridColor
 public Color getGridColor()
Returns the color used to draw grid lines. The default color is gray.

Returns:
the color used to draw grid lines
See Also:
setGridColor
 o setShowGrid
 public void setShowGrid(boolean b)
Sets whether the receiver draws grid lines around cells. If flag is true it does; if it is false it doesn't. There is no getShowGrid() method as the this state is held in two variables: showHorizontalLines and showVerticalLines each of which may be queried independently.

Parameters:
flag - true if table view should draw grid lines
See Also:
setShowVerticalLines, setShowHorizontalLines
 o setShowHorizontalLines
 public void setShowHorizontalLines(boolean b)
Sets whether the receiver draws horizontal lines between cells. If flag is true it does; if it is false it doesn't.

Parameters:
flag - true if table view should draw horizontal lines
See Also:
getShowHorizontalLines, setShowGrid, setShowVerticalLines
 o setShowVerticalLines
 public void setShowVerticalLines(boolean b)
Sets whether the receiver draws vertical lines between cells. If flag is true it does; if it is false it doesn't.

Parameters:
flag - true if table view should draw vertical lines
See Also:
getShowVerticalLines, setShowGrid, setShowHorizontalLines
 o getShowHorizontalLines
 public boolean getShowHorizontalLines()
Returns true if the receiver draws horizontal lines between cells, false if it doesn't. The default is true.

Returns:
true if the receiver draws horizontal lines between cells, false if it doesn't
See Also:
setShowHorizontalLines
 o getShowVerticalLines
 public boolean getShowVerticalLines()
Returns true if the receiver draws vertical lines between cells, false if it doesn't. The default is true.

Returns:
true if the receiver draws vertical lines between cells, false if it doesn't
See Also:
setShowVerticalLines
 o setAutoResizeMode
 public void setAutoResizeMode(int mode)
Sets the table's auto resize mode when the table is resized.

Parameters:
mode - One of 3 legal values: AUTO_RESIZE_OFF, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS
See Also:
getAutoResizeMode, sizeColumnsToFit
 o getAutoResizeMode
 public int getAutoResizeMode()
Returns auto resize mode of the table. The default is AUTO_RESIZE_ALL_COLUMNS.

Returns:
the autoResizeMode of the table
See Also:
setAutoResizeMode, sizeColumnsToFit
 o setAutoCreateColumnsFromModel
 public void setAutoCreateColumnsFromModel(boolean createColumns)
Sets the table's autoCreateColumnsFromModel flag. This method will call createDefaultColumnsFromModel() if createColumns is true.

Parameters:
createColumns - true if JTable should auto create columns
See Also:
getAutoCreateColumnsFromModel, createDefaultColumnsFromModel
 o getAutoCreateColumnsFromModel
 public boolean getAutoCreateColumnsFromModel()
Returns whether the table will create default columns from the model. If this is true, setModel() will clear any existing columns and create new columns from the new model. Also if the event in the the tableChanged() notification specified the entired table changed then the columns will be rebuilt. The default is true.

Returns:
the autoCreateColumnsFromModel of the table
See Also:
setAutoCreateColumnsFromModel, createDefaultColumnsFromModel
 o createDefaultColumnsFromModel
 public void createDefaultColumnsFromModel()
This method will create default columns for the table from the data model using the getColumnCount() and getColumnType() methods defined in the TableModel interface.

This method will clear any exsiting columns before creating the new columns based on information from the model.

See Also:
getAutoCreateColumnsFromModel
 o setDefaultRenderer
 public void setDefaultRenderer(Class columnClass,
                                TableCellRenderer renderer)
Set a default renderer to be used if no renderer has been set in a TableColumn.

See Also:
getDefaultRenderer, setDefaultEditor
 o getDefaultRenderer
 public TableCellRenderer getDefaultRenderer(Class columnClass)
Returns the renderer to be used when no renderer has been set in a TableColumn. During the rendering of cells the renderer is fetched from a Hashtable of entries according to the class of the cells in the column. If there is no entry for this columnClass the method returns the entry for the most specific superclass. The JTable installs entries for Object, Number and Boolean all which can be modified or replaced.

See Also:
setDefaultRenderer, getColumnClass
 o setDefaultEditor
 public void setDefaultEditor(Class columnClass,
                              TableCellEditor editor)
Set a default editor to be used if no editor has been set in a TableColumn. If no editing is required in a table or a particular column in a table use the isCellEditable() method in the TableModel interface to ensure that the JTable will not start an editor in these columns.

See Also:
isCellEditable, getDefaultEditor, setDefaultRenderer
 o getDefaultEditor
 public TableCellEditor getDefaultEditor(Class columnClass)
Returns the editor to be used when no editor has been set in a TableColumn. During the editing of cells the editor is fetched from a Hashtable of entries according to the class of the cells in the column. If there is no entry for this columnClass the method returns the entry for the most specific superclass. The JTable installs entries for Object, Number and Boolean all which can be modified or replaced.

See Also:
setDefaultEditor, getColumnClass
 o setSelectionMode
 public void setSelectionMode(int selectionMode)
Sets the table's selection mode to allow only single selections, a single contiguous interval, or multiple intervals. NOTE:
JTable provides all the methods for handling column and row selection. When setting states, such as setSelectionMode, it not only updates the mode for the row selection model but also sets similar values in the selection model of the columnModel. If you want to have states that is different between rows and columns you can get the columnModel and change that directly.

Both the row and column selection models for the JTable default to using a DefaultListSelectionModel so that JTable works the same way as the JList. See setSelectionMode() in JList for details about the modes.

See Also:
setSelectionMode
 o setRowSelectionAllowed
 public void setRowSelectionAllowed(boolean flag)
Sets whether the rows in this model can be selected.

See Also:
getRowSelectionAllowed
 o getRowSelectionAllowed
 public boolean getRowSelectionAllowed()
Returns true if rows can be selected.

Returns:
true if rows can be selected
See Also:
setRowSelectionAllowed
 o setColumnSelectionAllowed
 public void setColumnSelectionAllowed(boolean flag)
Sets whether the columns in this model can be selected.

See Also:
getColumnSelectionAllowed
 o getColumnSelectionAllowed
 public boolean getColumnSelectionAllowed()
Returns true if columns can be selected.

Returns:
true if columns can be selected.
See Also:
setColumnSelectionAllowed
 o setCellSelectionEnabled
 public void setCellSelectionEnabled(boolean flag)
Sets whether this table allows both a column selection and a row selection to exist at the same time. When set, this results in a facility to select a rectangular region of cells in the display. This flag over-rides the row and column selection modes ensuring that cell selection is possible whenever this flag is set.

See Also:
getCellSelectionEnabled
 o getCellSelectionEnabled
 public boolean getCellSelectionEnabled()
Returns true if simultaneous row and column selections are allowed

Returns:
true if simultaneous row and column selections are allowed
See Also:
setCellSelectionEnabled
 o selectAll
 public void selectAll()
If a column is selected, then this selects all columns. Similarly, if a row is selected, then, this selects all rows. If both a column and a row are selected at the time this method is invoked, then all columns and rows are selected.

 o clearSelection
 public void clearSelection()
Deselects all selected columns and rows. If empty selection is not allowed, then it leaves the first row selected.

 o setRowSelectionInterval
 public void setRowSelectionInterval(int index0,
                                     int index1)
Selects the rows from index0 to index1 inclusive.

Parameters:
index0 - one end of the interval.
index1 - other end of the interval
 o setColumnSelectionInterval
 public void setColumnSelectionInterval(int index0,
                                        int index1)
Selects the columns from index0 to index1 inclusive.

Parameters:
index0 - one end of the interval.
index1 - other end of the interval
 o addRowSelectionInterval
 public void addRowSelectionInterval(int index0,
                                     int index1)
Adds the rows from index0 to index0 inclusive to the current selection.

Parameters:
index0 - one end of the interval.
index1 - other end of the interval
 o addColumnSelectionInterval
 public void addColumnSelectionInterval(int index0,
                                        int index1)
Adds the columns from index0 to index0 inclusive to the current selection.

Parameters:
index0 - one end of the interval.
index1 - other end of the interval
 o removeRowSelectionInterval
 public void removeRowSelectionInterval(int index0,
                                        int index1)
Deselects the rows from index0 to index0 inclusive.

Parameters:
index0 - one end of the interval.
index1 - other end of the interval
 o removeColumnSelectionInterval
 public void removeColumnSelectionInterval(int index0,
                                           int index1)
Deselects the columns from index0 to index0 inclusive.

Parameters:
index0 - one end of the interval.
index1 - other end of the interval
 o getSelectedRow
 public int getSelectedRow()
Returns the index of the last row selected or added to the selection.

Returns:
the index of the last row selected or added to the selection, (lead selection) or -1 if no row is selected.
See Also:
getSelectedRows
 o getSelectedColumn
 public int getSelectedColumn()
Returns the index of the last column selected or added to the selection.

Returns:
the index of the last column selected or added to the selection, (lead selection) or -1 if no column is selected.
See Also:
getSelectedColumns
 o getSelectedRows
 public int[] getSelectedRows()
Returns the indices of all selected rows.

Returns:
an array of ints containing the indices of all selected rows, or an empty array if no row is selected.
See Also:
getSelectedRow
 o getSelectedColumns
 public int[] getSelectedColumns()
Returns the indices of all selected columns.

Returns:
an array of ints containing the indices of all selected columns, or an empty array if no column is selected.
See Also:
getSelectedColumn
 o getSelectedRowCount
 public int getSelectedRowCount()
Returns the number of selected rows.

Returns:
the number of selected rows, 0 if no columns are selected
 o getSelectedColumnCount
 public int getSelectedColumnCount()
Returns the number of selected columns.

Returns:
the number of selected columns, 0 if no columns are selected
 o isRowSelected
 public boolean isRowSelected(int row)
Returns true if the row at the specified index is selected

Returns:
true if the row at index row is selected, where 0 is the first row
Throws: IllegalArgumentException
if row is not in the valid range
 o isColumnSelected
 public boolean isColumnSelected(int column)
Returns true if the column at the specified index is selected

Returns:
true if the column at index column is selected, where 0 is the first column
Throws: IllegalArgumentException
if column is not in the valid range
 o isCellSelected
 public boolean isCellSelected(int row,
                               int column)
Returns true if the cell at the specified position is selected.

Returns:
true if the cell at index (row, column) is selected, where the first row and first column are at index 0
Throws: IllegalArgumentException
if row or column are not in the valid range
 o getSelectionForeground
 public Color getSelectionForeground()
Returns the foreground color for selected cells.

Returns:
the Color object for the foreground property
See Also:
setSelectionForeground, setSelectionBackground
 o setSelectionForeground
 public void setSelectionForeground(Color selectionForeground)
Set the foreground color for selected cells. Cell renderers can use this color to render text and graphics for selected cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
selectionForeground - the Color to use in the foreground for selected list items
See Also:
getSelectionForeground, setSelectionBackground, setForeground, setBackground, setFont
 o getSelectionBackground
 public Color getSelectionBackground()
Returns the background color for selected cells.

Returns:
the Color used for the background of selected list items
See Also:
setSelectionBackground, setSelectionForeground
 o setSelectionBackground
 public void setSelectionBackground(Color selectionBackground)
Set the background color for selected cells. Cell renderers can use this color to the fill selected cells.

The default value of this property is defined by the look and feel implementation.

This is a JavaBeans bound property.

Parameters:
selectionBackground - the Color to use for the background of selected cells
See Also:
getSelectionBackground, setSelectionForeground, setForeground, setBackground, setFont
 o getColumn
 public TableColumn getColumn(Object identifier)
Returns the TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals().

Parameters:
identifier - the identifier object
Returns:
the TableColumn object with matching identifier
Throws: IllegalArgumentException
if identifier is null or no TableColumn has this identifier
 o convertColumnIndexToModel
 public int convertColumnIndexToModel(int viewColumnIndex)
Return the index of the column in the model whose data is being displayed in the column viewColumnIndex in the display. Returns viewColumnIndex unchanged when viewColumnIndex is less than zero.

See Also:
convertColumnIndexToView
 o convertColumnIndexToView
 public int convertColumnIndexToView(int modelColumnIndex)
Return the index of the column in the view which is displaying the data from the column modelColumnIndex in the model. Returns -1 if this column is not being displayed. Returns modelColumnIndex unchanged when modelColumnIndex is less than zero.

See Also:
convertColumnIndexToModel
 o getRowCount
 public int getRowCount()
Returns the number of rows in the table.

See Also:
getColumnCount
 o getColumnCount
 public int getColumnCount()
Returns the number of columns in the column model, note this may be different to the number of columns in the table model.

Returns:
the number of columns in the table
See Also:
getRowCount
 o getColumnName
 public String getColumnName(int column)
Returns the name of the column at the specified view position.

Returns:
the name of the column at position column in the view where the first column is column 0.
 o getColumnClass
 public Class getColumnClass(int column)
Returns the type of the column at the specified view position.

Returns:
the type of the column at position column in the view where the first column is column 0.
 o getValueAt
 public Object getValueAt(int row,
                          int column)
Returns the cell value at row and column.

NOTE: The column is specified in the table view's display order, and not in the TableModel's column order. This is an important distinction because as the user rearranges the columns in the table, what is at column 2 changes. Meanwhile the user's actions never affect the model's column ordering.

Parameters:
row - the row whose value is to be looked up
column - the column whose value is to be looked up
Returns:
the Object at the specified cell
 o setValueAt
 public void setValueAt(Object aValue,
                        int row,
                        int column)
Sets the value for the cell at row and column. aValue is the new value.

Parameters:
aValue - the new value
row - the row whose value is to be changed
column - the column whose value is to be changed
See Also:
getValueAt
 o isCellEditable
 public boolean isCellEditable(int row,
                               int column)
Returns true if the cell at row and column is editable. Otherwise, setValueAt() on the cell will not change the value of that cell.

Parameters:
row - the row whose value is to be looked up
column - the column whose value is to be looked up
Returns:
true if the cell is editable.
See Also:
setValueAt
 o addColumn
 public void addColumn(TableColumn aColumn)
Appends aColumn to the end of the array of columns held by the JTable's column model. If the header value of aColumn is null, sets the header value of aColumn to the name returned by getModel().getColumnName().

To add a column to the JTable to display the modelColumn'th column of data in the model, with a given width, cellRenderer and cellEditor you can use:

      addColumn(new TableColumn(modelColumn, width, cellRenderer, cellEditor));
  
[All of the other constructors in the TableColumn can be used in place of this one.] The model column is stored inside the TableColumn and is used during rendering and editing to locate the appropriate data values in the model. The model column does not change when columns are reordered in the view.

Parameters:
aColumn - The TableColumn to be added
See Also:
removeColumn
 o removeColumn
 public void removeColumn(TableColumn aColumn)
Removes aColumn from the JTable's array of columns. Note: this method does not remove the column of data from the model it just removes the TableColumn that was displaying it.

Parameters:
aColumn - The TableColumn to be removed
See Also:
addColumn
 o moveColumn
 public void moveColumn(int column,
                        int targetColumn)
Moves the column column to the position currently occupied by the column targetColumn. The old column at targetColumn is shifted left or right to make room.

Parameters:
column - the index of column to be moved
targetColumn - the new index of the column
 o columnAtPoint
 public int columnAtPoint(Point point)
Returns the index of the column that point lies in, or -1 if it lies outside the receiver's bounds.

Returns:
the index of the column that point lies in, or -1 if it lies outside the receiver's bounds
See Also:
rowAtPoint
 o rowAtPoint
 public int rowAtPoint(Point point)
Returns the index of the row that point lies in, or -1 if is not in the range [0, getRowCount()-1].

Returns:
the index of the row that point lies in, or -1 if it is not in the range [0, getRowCount()-1]
See Also:
columnAtPoint
 o getCellRect
 public Rectangle getCellRect(int row,
                              int column,
                              boolean includeSpacing)
Returns a rectangle locating the cell that lies at the intersection of row and column. If includeSpacing is true then the value returned includes the intercellSpacing margin. If it is false, then the returned rect is inset by half of intercellSpacing. (This is the true frame of the cell)

Parameters:
row - the row to compute
column - the column to compute
includeSpacing - if true, the rect returned will include the correct intercellSpacing
Returns:
the rectangle containing the cell at index row,column
Throws: IllegalArgumentException
If row or column are not in the valid range.
 o sizeColumnsToFit
 public void sizeColumnsToFit(boolean lastColumnOnly)
This method will resize one or more columns of the table so that the sum width of all columns will equal to the width of the table. If lastColumnOnly is true, then it will try to resize the last column only to make it fit, but if it runs into either the minimum size limit of the column or maximum size limit, then it will change the next to last column also, etc. If lastColumnOnly is false, then it will spread the size delta proportionately to all the columns, while respecting each column's max and min size limits. Also, notifications of each column width change will be sent out as they are resized.

Note: It is possible that even after this method is called, the total width of the columns is still not be equal to the width of the table. eg. A table with a single column, the column has a minimum width of 20, and the tableView has a width of 10. And there is nothing I can do about that.

Parameters:
lastColumnOnly - Try to change the last column only if true
See Also:
setWidth
 o getToolTipText
 public String getToolTipText(MouseEvent event)
Overrides JComponent's setToolTipText method to allow use of the renderer's tips (if the renderer has text set).

NOTE: For JTable to properly display tooltips of its renderers JTable must be a registered component with the ToolTipManager. This is done automatically in initializeLocalVars(), but if at a later point JTable is told setToolTipText(null) it will unregister the table component, and no tips from renderers will display anymore.

Overrides:
getToolTipText in class JComponent
See Also:
getToolTipText
 o editCellAt
 public boolean editCellAt(int row,
                           int column)
Programmatically starts editing the cell at row and column, if the cell is editable.

Parameters:
row - the row to be edited
column - the column to be edited
Returns:
false if for any reason the cell cannot be edited.
Throws: IllegalArgumentException
If row or column are not in the valid range
 o editCellAt
 public boolean editCellAt(int row,
                           int column,
                           EventObject e)
Programmatically starts editing the cell at row and column, if the cell is editable. To prevent the JTable from editing a particular table, column or cell value, return false from the isCellEditable() method in the TableModel interface.

Parameters:
row - the row to be edited
column - the column to be edited
e - event to pass into shouldSelectCell
Returns:
false if for any reason the cell cannot be edited.
Throws: IllegalArgumentException
If row or column are not in the valid range
 o isEditing
 public boolean isEditing()
Returns true is the table is editing a cell.

Returns:
true is the table is editing a cell
See Also:
editingColumn, editingRow
 o getEditorComponent
 public Component getEditorComponent()
If the receiver is currently editing this will return the Component that was returned from the CellEditor.

Returns:
Component handling editing session
 o getEditingColumn
 public int getEditingColumn()
This returns the index of the editing column.

Returns:
the index of the column being edited
See Also:
editingRow
 o getEditingRow
 public int getEditingRow()
Returns the index of the editing row.

Returns:
the index of the row being edited
See Also:
editingColumn
 o getUI
 public TableUI getUI()
Returns the L&F object that renders this component.

Returns:
the TableUI object that renders this component
 o setUI
 public void setUI(TableUI ui)
Sets the L&F object that renders this component.

Parameters:
ui - the TableUI L&F object
See Also:
getUI
 o updateUI
 public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.

Overrides:
updateUI in class JComponent
See Also:
updateUI
 o getUIClassID
 public String getUIClassID()
Returns the name of the L&F class that renders this component.

Returns:
"TableUI"
Overrides:
getUIClassID in class JComponent
See Also:
getUIClassID, getUI
 o setModel
 public void setModel(TableModel newModel)
Sets the data model for this table to newModel and registers with for listner notifications from the new data model.

Parameters:
newModel - the new data source for this table
Throws: IllegalArgumentException
if newModel is null
See Also:
getModel
 o getModel
 public TableModel getModel()
Returns the TableModel that provides the data displayed by the receiver.

Returns:
the object that provides the data displayed by the receiver
See Also:
setModel
 o setColumnModel
 public void setColumnModel(TableColumnModel newModel)
Sets the column model for this table to newModel and registers with for listner notifications from the new column model. Also sets the column model of the JTableHeader to newModel.

Parameters:
newModel - the new data source for this table
Throws: IllegalArgumentException
if newModel is null
See Also:
getColumnModel
 o getColumnModel
 public TableColumnModel getColumnModel()
Returns the TableColumnModel that contains all column inforamtion of this table.

Returns:
the object that provides the column state of the table
See Also:
setColumnModel
 o setSelectionModel
 public void setSelectionModel(ListSelectionModel newModel)
Sets the row selection model for this table to newModel and registers with for listner notifications from the new selection model.

Parameters:
newModel - the new selection model
Throws: IllegalArgumentException
if newModel is null
See Also:
getSelectionModel
 o getSelectionModel
 public ListSelectionModel getSelectionModel()
Returns the ListSelectionModel that is used to maintain row selection state.

Returns:
the object that provides row selection state. Or null if row selection is not allowed.
See Also:
setSelectionModel
 o tableChanged
 public void tableChanged(TableModelEvent e)
The TableModelEvent should be constructed in the co-ordinate system of the model, the appropriate mapping to the view co-ordinate system is performed by the JTable when it recieves the event.

 o columnAdded
 public void columnAdded(TableColumnModelEvent e)
Tells listeners that a column was added to the model.

See Also:
TableColumnModelListener
 o columnRemoved
 public void columnRemoved(TableColumnModelEvent e)
Tells listeners that a column was removed from the model.

See Also:
TableColumnModelListener
 o columnMoved
 public void columnMoved(TableColumnModelEvent e)
Tells listeners that a column was repositioned.

See Also:
TableColumnModelListener
 o columnMarginChanged
 public void columnMarginChanged(ChangeEvent e)
Tells listeners that a column was moved due to a margin change.

See Also:
TableColumnModelListener
 o columnSelectionChanged
 public void columnSelectionChanged(ListSelectionEvent e)
Tells listeners that the selection model of the TableColumnModel changed.

See Also:
TableColumnModelListener
 o valueChanged
 public void valueChanged(ListSelectionEvent e)
Tells listeners that the selection changed.

See Also:
ListSelectionListener
 o editingStopped
 public void editingStopped(ChangeEvent e)
Invoked when editing is finished. The changes are saved, the editor object is discarded, and the cell is rendered once again.

See Also:
CellEditorListener
 o editingCanceled
 public void editingCanceled(ChangeEvent e)
Invoked when editing is canceled. The editor object is discarded and the cell is rendered once again.

See Also:
CellEditorListener
 o setPreferredScrollableViewportSize
 public void setPreferredScrollableViewportSize(Dimension size)
Sets the preferred size of the viewport for this table.

Parameters:
size - a Dimension object specifying the preferredSize of a JViewport whose view is this table
See Also:
getPreferredScrollableViewportSize
 o getPreferredScrollableViewportSize
 public Dimension getPreferredScrollableViewportSize()
Returns the preferred size of the viewport for this table.

Returns:
a Dimension object containing the preferredSize of the JViewport which displays this table
See Also:
getPreferredScrollableViewportSize
 o getScrollableUnitIncrement
 public int getScrollableUnitIncrement(Rectangle visibleRect,
                                       int orientation,
                                       int direction)
Returns the scroll increment that completely exposes one new row or column (depending on the orientation).

This method is called each time the user requests a unit scroll.

Parameters:
visibleRect - The view area visible within the viewport
orientation - Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
direction - Less than zero to scroll up/left, greater than zero for down/right.
Returns:
The "unit" increment for scrolling in the specified direction
See Also:
getScrollableUnitIncrement
 o getScrollableBlockIncrement
 public int getScrollableBlockIncrement(Rectangle visibleRect,
                                        int orientation,
                                        int direction)
Returns The visibleRect.height or visibleRect.width, depending on the table's orientation.

Returns:
The visibleRect.height or visibleRect.width per the orientation.
See Also:
getScrollableBlockIncrement
 o getScrollableTracksViewportWidth
 public boolean getScrollableTracksViewportWidth()
Returns false to indicate that the width of the viewport does not determine the width of the table.

Returns:
false
See Also:
getScrollableTracksViewportWidth
 o getScrollableTracksViewportHeight
 public boolean getScrollableTracksViewportHeight()
Returns false to indicate that the height of the viewport does not determine the height of the table.

Returns:
false
See Also:
getScrollableTracksViewportHeight
 o createDefaultRenderers
 protected void createDefaultRenderers()
 o createDefaultEditors
 protected void createDefaultEditors()
Creates default cell editors for Objects, numbers, and boolean values.

 o initializeLocalVars
 protected void initializeLocalVars()
Initializes table properties to their default values.

 o createDefaultDataModel
 protected TableModel createDefaultDataModel()
Returns the default table model object which is a DefaultTableModel. Subclass can override this method to return a different table model object.

Returns:
the default table model object
 o createDefaultColumnModel
 protected TableColumnModel createDefaultColumnModel()
Returns the default column model object which is a DefaultTableColumnModel. Subclass can override this method to return a different column model object

Returns:
the default column model object
 o createDefaultSelectionModel
 protected ListSelectionModel createDefaultSelectionModel()
Returns the default selection model object which is a DefaultListSelectionModel. Subclass can override this method to return a different selection model object.

Returns:
the default selection model object
 o createDefaultTableHeader
 protected JTableHeader createDefaultTableHeader()
Returns the default table header object which is a JTableHeader. Subclass can override this method to return a different table header object

Returns:
the default table header object
 o resizeAndRepaint
 protected void resizeAndRepaint()
Properly sizes the receiver and its header view, and marks it as needing display. Also resets cursor rectangles for the header view and line scroll amounts for the JScrollPane.

 o getCellEditor
 public TableCellEditor getCellEditor()
Return the cellEditor.

Returns:
the TableCellEditor that does the editing
See Also:
cellEditor
 o setCellEditor
 public void setCellEditor(TableCellEditor anEditor)
Set the cellEditor variable.

Parameters:
anEditor - the TableCellEditor that does the editing
See Also:
cellEditor
 o setEditingColumn
 public void setEditingColumn(int aColumn)
Set the editingColumn variable.

See Also:
editingColumn
 o setEditingRow
 public void setEditingRow(int aRow)
Set the editingRow variable.

See Also:
editingRow
 o isOpaque
 public boolean isOpaque()
Returns true to indicate that this component paints every pixel in its range. (In other words, it does not have a transparent background or foreground.)

Returns:
true
Overrides:
isOpaque in class JComponent
See Also:
isOpaque
 o prepareEditor
 public Component prepareEditor(TableCellEditor editor,
                                int row,
                                int column)
Sets up the specified editor using the value at the specified cell.

Parameters:
editor - the TableCellEditor to set up
row - the row of the cell to edit, where 0 is the first
column - the column of the cell to edit, where 0 is the first
 o removeEditor
 public void removeEditor()
Discard the editor object and return the real estate it used to cell rendering.

 o getAccessibleContext
 public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent

Returns:
the AccessibleContext of this JComponent
Overrides:
getAccessibleContext in class JComponent

All Packages  Class Hierarchy  This Package  Previous  Next  Index